import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:hc_bot_pro/chat/index.dart';
import 'package:pag_flutter/pag_flutter.dart';

import '../../state.dart';

class DoctorView extends StatefulWidget {
  const DoctorView({super.key});

  @override
  State<DoctorView> createState() => _DoctorViewState();
}

class _DoctorViewState extends State<DoctorView> {
  late final PAGController controller;

  @override
  void initState() {
    super.initState();
    controller = PAGController()..play();
  }

  @override
  Widget build(BuildContext context) {
    final vc = Get.find<ChatController>();
    switch (vc.state.status) {
      case HCAIBotStatus.speaking:
        return Container(
          child: PAGView.asset(
            "assets/images/siri_doctor_speaking.pag",
            controller: controller,
            repeatCount: -1,
          ),
        );
      default:
        return Container(
          child: PAGView.asset(
            "assets/images/siri_doctor_listening.pag",
            controller: controller,
            repeatCount: -1,
          ),
        );
    }
  }

  @override
  void dispose() {
    super.dispose();
    controller.dispose();
  }
}
